package gat.common.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author sxq
 * @date 2021/12/22
 */

@AllArgsConstructor
@Getter
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum SeqNoEnum {

    PAYMENT_NO("payment:no", "P", "支付单号", "%06d"),
    TOP_UP("top:up", "TU", "充值订单", "%01d"),
    APPLY_FREEZE("apply:freeze", "AF", "申请冻结", "%01d"),
    APPLY_THAW("apply:thaw", "AT", "申请解冻", "%01d"),
    USER_SETTLE("user:settle", "US", "用户结算账户", "%06d"),
    CHANNEL_SETTLE("channel:settle", "CS", "渠道结算账户", "%06d"),
    No_PREFIX("", "", "id无前缀", "%01d"),
    ;

    private final String key;
    private final String prefix;
    private final String msg;
    private final String digit;

    /**
     * 根据code,获取描述信息
     *
     * @param key
     * @return
     */
    @JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
    public static SeqNoEnum getByKey(@JsonProperty("key") String key) {
        for (SeqNoEnum value : values()) {
            if (value.getKey().equals(key)) {
                return value;
            }
        }
        return null;
    }

}
